Skip to content

feat: Password support for /e/authorize endpoint - #1088

Merged
pmathew92 merged 8 commits into
v5_developmentfrom
feat/password
Oct 30, 2026
Merged

pmathew92 merged 8 commits into
v5_developmentfrom
feat/password

Conversation

@pmathew92

Copy link
Copy Markdown
Member

Changes

This PR adds the support for ROPG in the /e/authorize endpoint. On successful verification the auth0-server returns an authorization code which is exchanged for a valid set of Credentials.

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. Since this library has unit testing, tests should be added for new functionality and existing tests should complete without errors.

  • This change adds unit test coverage

  • This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Team
  • Run ID: f7fa1f25-4165-450f-9394-c1e5f9bfd43c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from feat/embedded_mfa to v5_development October 23, 2026 06:39
@pmathew92
pmathew92 marked this pull request as ready for review October 26, 2026 05:51
@pmathew92
pmathew92 requested a review from a team as a code owner October 26, 2026 05:51
when (e.error) {
is EmbeddedAuthError.InsufficientAuthorization -> { /* continuation → VerifyPassword */ }
EmbeddedAuthError.InvalidRequest -> {
/* the username was rejected (e.g. "Invalid username format.") — fix the input and identify again */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After InvalidRequest the SDK clears the session, so calling identify again fails with NoActiveSession. Suggest: "fix the input and restart with authorize()", as in the InvalidRequest KDoc and authorize.md.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return this
}

fun willReturnInvalidUsernameFormat(): EmbeddedAuthMockServer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

willReturnInvalidUsernameFormat() isn't used by any test. A test for identify(USERNAME) returning InvalidRequest (session cleared) would have caught the docs issue in password-authorize.md.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

@Test
public fun `verifyPassword await keeps the session for retry when the token exchange fails`(): Unit = runTest {

@NandanPrabhu NandanPrabhu Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: this test keeps the session after a failed token exchange (the token response has no id_token) and retries verifyPassword with the same auth_session. That retry runs /e/authorize again to get a new code, so it only works if the server accepts the same auth_session after it has already issued a code. The mock server can't tell us that. Can we confirm it with the server team?

For a network error on the token call the code may still be unused, so keeping the session is right there. We'd like both SDKs to behave the same, so we can align Auth0.swift once this is confirmed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Retrying with the same session is not correct .

Comment thread auth0/src/main/java/com/auth0/android/embedded/EmbeddedAuthError.kt
}

@Test
public fun `verifyPassword await should return credentials`(): Unit = runTest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the new verifyPassword tests use execute() or await(). Please add one test with start(callback) (success and failure), since that path goes through AdvancingRequest.start.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally avoided. await internally calls start. We are just writing duplicate tests.

/** The password is submitted as typed — never trimmed — and masked on screen. */
@Composable
private fun VerifyPasswordCard(onVerify: (String) -> Unit) {
var password by rememberSaveable { mutableStateOf("") }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rememberSaveable writes the password to the saved-state Bundle. Please use remember for the password field; samples get copied into real apps.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@utkrishtsahu
utkrishtsahu dismissed their stale review October 30, 2026 08:47

Posted by mistake

EMAIL,
/** A phone number. */
PHONE,
/** A username. */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design doc says the username field can hold either a username or an email ({user_name} / {email}). This KDoc just says "A username." Could we say that an email is also valid, and mention it in password-authorize.md?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already an email. The intention was password can be used with both email and username. will update the design doc to clear the confusion. But this is correct

onSubmit = { viewModel.identifyUsername(it) },
)

NextAction.VerifyPassword -> VerifyPasswordCard(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample never reads reason, so a wrong password just shows the password card again with no message. authorize.md shows how to surface INVALID_IDENTIFIER_OR_PASSWORD, so the sample should do the same.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

utkrishtsahu
utkrishtsahu previously approved these changes Oct 30, 2026
@pmathew92
pmathew92 merged commit 58e1fa2 into v5_development Oct 30, 2026
7 of 9 checks passed
@pmathew92
pmathew92 deleted the feat/password branch October 30, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants